<?php
namespace WebAdmin\Controller;
use WebAdmin\Controller\BaseController;
class FileController extends BaseController {

	//ThinkPHP的构造函数
	public function _initialize() {
		//自动加载的类
		new \Org\Admin_autoload();
	}

    public function index(){
    	
    }
    
   
    public function editor()
    {
    	if (!empty($_FILES['imgFile']['name'])) {
    		import ( '@.ORG.UploadFile' );
    		$upload = new \UploadFile ();
    		// 设置文件大小
    		$upload->maxSize = 3292200;
    		// 设置文件保存规则唯一
    		$upload->saveRule = 'uniqid';
    		// 设置上传文件的格式
    		$upload->allowExts = array ('jpg','png','jpeg','gif');
    		// 保存路径
    		$root_path = dirname(dirname(dirname(dirname(__FILE__))));
    		$upload->savePath = $root_path.'/www/Public/Uploads/';
    		// 设置需要生成缩略图，仅对图像文件有效
    		$upload->thumb = false;
    		// 删除原图
    		$upload->thumbRemoveOrigin = false;
    		if (! $upload->upload ()) {
    			$this->error ( $upload->getErrorMsg () );
    		} else {
    			// $this->success('上传成功');
    			// 获取上传文件的信息
    			$file = $upload->getUploadFileInfo ();
    		}
    		if ($file) {
    			$file[0]['savepath'] = str_replace($root_path."/www","",$file[0]['savepath']);
    			$file_url ="http://".FRONT_SITE_NAME.str_replace("./","/",$file[0]['savepath']) . $file[0]['savename'];
    			echo json_encode(array('error' => 0, 'url' => $file_url));//返回的信息必须是json格式的
    		} 
    	}
    }
    
    public function manager(){
    	
    }
       
    
}